﻿@model MAPDavy.Entities.Term

@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section JavaScript{
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.ui.datepicker.js")" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#TestingStartDate").datepicker({
                changeMonth: true,
                changeYear: true,
                dateFormat: 'dd/mm/yy'
            });
            $("#TestingEndDate").datepicker({
                changeMonth: true,
                changeYear: true,
                dateFormat: 'dd/mm/yy'
            });

            $('#guardar').click(function () {

                var _map = $("#MapId option:selected");

                $.post('@Url.Action("ValidateMAP", "Term")',
                       { mapId: _map.val()},
                       function (ok) {
                            if (ok) {
                                $('form').submit();            
                            }
                            else {
                                jAlert("No se Puede crear el Test con el MAP: <b>" + _map.text() +"</b>, Porque ya Existe.", "Advertencia");
                            }
                       },
                       "json"
                       );
            });
        });
    </script>
}
<div class="cpanel ui-widget ui-widget-content ui-corner-all">
    <table class="toolbar">
        <tr>
            <td valign="middle" >
                <img src="@Url.Content("~/Content/images/newTask.png")" alt="evaluaciones" />
            </td>
            <td class="tdHeader"><span class="header">Crear Evaluación</span></td>
            <td class="cerrado"><center>
                <a href="#" id="guardar">
                   <img src="@Url.Content("~/Content/images/save.png")" title="Guardar" alt="Guardar" />
                    <br /><span class="label">Guardar</span>
                </a></center>
            </td>
            <td><center>
                <a href="@Url.Action("Index", "Term")">
                    <img src="@Url.Content("~/Content/images/back.png")" title="Candelar" alt="Candelar" />
                    <br /><span class="label">Cancelar</span>
                </a></center>
            </td>
        </tr>
    </table>
</div>
@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Evaluación</legend>
        <div class="editor-label">             
            @Html.LabelFor(model => model.MapId, "MAP")
        </div>
        <div class="editor-field">
            @Html.DropDownList("MapId")
            @Html.ValidationMessageFor(model => model.MapId)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.NameTerm, "Nombre Evaluación")
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.NameTerm)
            @Html.ValidationMessageFor(model => model.NameTerm)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Description)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Description)
            @Html.ValidationMessageFor(model => model.Description)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.TestingStartDate,"Inicio de Evaluaciones")
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.TestingStartDate)
            @Html.ValidationMessageFor(model => model.TestingStartDate)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.TestingEndDate,"Fin de Evaluaciones")
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.TestingEndDate)
            @Html.ValidationMessageFor(model => model.TestingEndDate)
        </div>

        <div class="editor-field">
            @Html.LabelFor(model => model.Cerrado)
            @Html.CheckBoxFor(model => model.Cerrado, new { @id = "isClose", @name = "isClose" })
            @Html.ValidationMessageFor(model => model.Cerrado)
        </div>  
    </fieldset>
}